import Vue from 'vue';
import App from './App.vue';
import router from './router';
import './plugins/element.js';
import './assets/css/global.css';
import './assets/fonts/iconfont.css';
import axios from './axios';
import TreeTable from 'vue-table-with-tree-grid';
// 导入vue-quill-editor（富文本编辑器）
import VueQuillEditor from 'vue-quill-editor';
// 导入vue-quill-editor的样式
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css'

Vue.config.productionTip = false;

Vue.filter('dateFormat', function (date) {
  function parse(val) {
    return (val + '').padStart(2, '0');
  }
  date = new Date(date);
  return `${date.getFullYear()}-${parse(date.getMonth() +
    1)}-${parse(date.getDate())} ${parse(date.getHours())}:${parse(date.getMinutes())}:${parse(date.getSeconds())}`;
});

axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/";

axios.interceptors.request.use(config => {
  NProgress.start();
  config.headers.Authorization = window.sessionStorage.getItem('token');
  return config;
});
axios.interceptors.response.use(config => {
  NProgress.done();
  return config;
});

Vue.prototype.$http = axios;

Vue.component('tree-table', TreeTable);
Vue.use(VueQuillEditor);

new Vue({
  router,
  render: h => h(App)
}).$mount('#app');
